#include <vector>
using namespace std;

struct Fragment {
    int length;
    int offset;
};

vector<Fragment> fragmentPacket(int packetLength, const vector<int>& pathMTUs) {
    vector<Fragment> fragments;
    int dataLength = packetLength - 20; // 数据部分长度
    int offset = 0;
    const int headerSize = 20;

    for (int mtu : pathMTUs) {
        int maxDataPerFragment = mtu - headerSize;
        maxDataPerFragment = maxDataPerFragment - (maxDataPerFragment % 8); // 确保是8的倍数

        while (dataLength > 0) {
            int fragmentData = min(maxDataPerFragment, dataLength);
            int fragmentLength = fragmentData + headerSize;
            fragments.push_back({fragmentLength, offset});
            dataLength -= fragmentData;
            offset += fragmentData / 8;
        }
    }
    return fragments;
}